package com.zt.bus.wx.config;

import com.github.binarywang.wxpay.config.WxPayConfig;
import com.github.binarywang.wxpay.service.WxPayService;
import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
import com.zt.util.PropertiesUtil;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 微信支付相关配置
 * <p>
 * Created by bjliumingbo on 2017/5/12.
 */
@Configuration
public class WxPayConfiguration {

	@Bean
	public WxPayConfig payConfig() {
		WxPayConfig payConfig = new WxPayConfig();
		payConfig.setAppId(PropertiesUtil.getProperty("wxPay.appId"));
		payConfig.setMchId(PropertiesUtil.getProperty("wxPay.mchId"));
		payConfig.setMchKey(PropertiesUtil.getProperty("wxPay.mchKey"));
		payConfig.setSubAppId(PropertiesUtil.getProperty("wxPay.subAppId"));
		payConfig.setSubMchId(PropertiesUtil.getProperty("wxPay.subMchId"));
		payConfig.setKeyPath(PropertiesUtil.getProperty("wxPay.keyPath"));

		return payConfig;
	}

	@Bean
	public WxPayService payService() {
		WxPayService payService = new WxPayServiceImpl();
		payService.setConfig(payConfig());
		return payService;
	}
}